package com.ljc.dto;


import lombok.Data;

/**
 * @author clj
 * @date 2022/9/22
 * @desc
 */
@Data
public class ListNode {
    public int val;
    public ListNode next;
    public ListNode(int val) {
        this.val = val;
        this.next = null;
    }

    //判断两个ListNode是否相同
    public static boolean isSame(ListNode l1, ListNode l2) {
        if (l1 == null && l2 == null) {
            return true;
        }
        while (l1 != null && l2 != null) {
            if (l1.val != l2.val) {
                return false;
            } else {
                l1 = l1.next;
                l2 = l2.next;
            }
        }
        return l1 == null && l2 == null;
    }
}
